import Taro from '@tarojs/taro';
import  { Component } from 'react'

import { View, Button, Textarea } from '@tarojs/components';
import './replycontent.less';

class ReplyContent extends Component {

  state = {
    value: '',
  };

  btnOK() {
    const {value} = this.state;
    // @ts-ignore
    const {onOKReplyContent} = this.props;
    if (value) {
      onOKReplyContent && onOKReplyContent(value)
    } else {
      Taro.showToast({ title: '请输入评论内容', icon: 'none' })
    }
  }

  btnCancel() {
    // @ts-ignore
    const {onCancelReplyContent} = this.props;
    onCancelReplyContent && onCancelReplyContent();
  }

  changeContent(event) {
    if (event && event.target) {
      this.setState({ value: event.target.value });
    }
  }

  render() {
    return (
      <View className='replycontent'>
        <Textarea onInput={this.changeContent.bind(this)} className='replycontent-text' placeholder='请输入回复内容' />
        <View className='replycontent-btngroup'>
          <Button onClick={this.btnOK.bind(this)} className='btn'>确定</Button>
          <Button onClick={this.btnCancel.bind(this)} className='btn'>取消</Button>
        </View>
      </View>
    )
  }
}
export default ReplyContent;
